package com.xcdh.test.provider;

import com.xcdh.test.entity.One;
import org.apache.ibatis.jdbc.SQL;

/**
 * OneProvider
 * Created by wjg on 2024/2/2.
 */
public class OneProvider {

    public String queryById(One one){
        return new SQL(){{
            SELECT("id , id detail_id , name , row_number, number").FROM("test_one").WHERE("id = #{one.id}") ;
        }}.toString() ;
    }

    public String findChild(Integer id){
        return new SQL(){{
            SELECT("o.* ,m.title As 'child.title' ").FROM("test_one o")
                    .LEFT_OUTER_JOIN("test_many m on m.one_id = o.id")
                    .WHERE("o.id = #{id}") ;
        }}.toString() ;
    }
}
